package com.craftcomputing.client.SearchResult.Label;

import com.craftcomputing.client.Entry.CodeEntry;
import com.craftcomputing.client.Entry.EntryPanel;
import com.google.gwt.json.client.*;
import com.google.gwt.user.client.Window;

public class CodeSearchResultLabel extends SearchResultLabel {

	public CodeSearchResultLabel() {}
	public CodeSearchResultLabel(JSONValue json) {
		super(json);
	}
	public EntryPanel makeEntryPanel(){
		return new CodeEntry();
	}
	protected void fillData(JSONValue json){
		name = json.isObject().get("name").toString().replaceAll("\"", "");
		JSONValue image = json.isObject().get("lbimage");
		//Window.alert("jsonarray: " + json.toString());
		//Window.alert("image: " + image.toString());
		if(image != null){
			//Window.alert("lbimage: " + image.toString());
			imageLoc = image.toString().replaceAll("\"", "");
		}
		if(imageLoc.equals(""))
		{
			//Window.alert("not lbimage");
			image = json.isObject().get("pbimage");
			if (!imageLoc.equals("")){
				//Window.alert("pbimage: " + image.toString());
				imageLoc = image.toString().replaceAll("\"", "");
			}
			else{
				//Window.alert("default: " + "mainimages/01_11a.jpg");
				imageLoc = "mainimages/01_11a.jpg";
			}
		}
	}
}
